#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "../json/json.h"
#include "ui_ruleswindow.h"
#include <QResizeEvent>
#include <QWindowStateChangeEvent>

using namespace Json;

class RulesWindow : public QMainWindow, public Ui::RulesWindow
{
	Q_OBJECT

	public:
		RulesWindow(QMainWindow *parent=0);
		void init(Value *settings);
		void fillTable(Value rules);
		void fillRates(QMap <QString,QString> rates);
	private:
		void doWindowGeometry(bool init);
		void selectRow(int row);
		int getSelectedId();
		Value *settings;
		void createActions();
		void startRefreshTimer();
		QTimer *timer;
		
	protected:
		bool event(QEvent * event);
		void contextMenuEvent(QContextMenuEvent *event);

	protected slots:
		void handleCellClicked(int row,int column);
		void handleCellDoubleClicked(int row,int column);
		void actionDeleteRule();
		void actionEditRule();
		void actionAddRule();
		void askRates();

	signals:
		void wantRates();
		void deleteRule(int ruleID);
		void editRule(int ruleID);
		void addRule();
		void showSettings();
};

#endif
